#ifndef GPIO_H_
#define GPIO_H_

#include <targets/lpc2378.h>

#define DIN_VALUE(in)(FIO1PIN &  0x00400000)
#define DIN_SELECT(in) {FIO1DIR |= 0x03800000; FIO1CLR = 0x03800000; FIO1SET = (in&7)<<23;}
#define AIN_SELECT(in) DIN_SELECT(in)

#define ALARM1()  (FIO0PIN &  0x08000000)
#define ALARM2()  (FIO0PIN &  0x10000000)

#define DOUT1_ON()  {FIO1DIR |= 0x04000000; FIO1CLR |= 0x04000000;}
#define DOUT1_OFF() {FIO1DIR |= 0x04000000; FIO1SET |= 0x04000000;}
#define DOUT2_ON()  {FIO1DIR |= 0x08000000; FIO1CLR |= 0x08000000;}
#define DOUT2_OFF() {FIO1DIR |= 0x08000000; FIO1SET |= 0x08000000;}

#define CASE_OPEN()		((FIO0PIN & 0x04000000)!=0)


#define gpio_enable() (SCS |= SCS_GPIOM)


#endif /* GPIO_H_ */